package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface UserMapper {
    @Select("select * from user where openid = #{openid}")
    User getByOpenId(String openid);

    void insert(User user);

    /**
     * 微信支付
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{id}")
    User getById(Long userId);

    @Select("select count(*) from user where date_format(create_time,'%Y-%m-%d') < #{begin}")
    Integer getTotalCountBeforeDate(LocalDate begin);

    @Select("select count(*) from user where date_format(create_time,'%Y-%m-%d') = #{begin}")
    Integer getNewUserByDate(LocalDate date);
}
